package com.cskaoyan.config2;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 注册一个DruidDataSource 2.0
 * @author stone
 * @date 2022年1月4日16:06:31
 */
//@Configuration
//@Data //用到了set方法
//@ConfigurationProperties(prefix = "druid.datasource")
public class DruidDataSourceConfiguration {


    String driver;
    String url;
    String username;
    String password;
    @Bean
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driver);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }
}
